﻿using ChromeTabs;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using JiveMessenger.CustomControls;
using JiveMessenger.Models;
using JiveMessenger.Utilities;
using JiveMessenger.ViewModels;
using JmShared;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace JiveMessenger.SampleData
{
    class SampleViewModelMainWindow : ViewModelBase, IViewModelMainWindow
    {
        public RelayCommand EditFontCommand { get; set; }
        public RelayCommand GetEmoticonsCommand { get;  set; }
        public RelayCommand<bool> LogoutCommand { get;  set; }
        public RelayCommand OpenOptionsCommand { get;  set; }
        public RelayCommand ViewLogCommand { get;  set; }
        public RelayCommand WindowLoadedCommand { get;  set; }
        public RelayCommand<KeyEventArgs> PreviewKeyUpCommand { get;  set; }
        public RelayCommand HideMenuCommand { get;  set; }
        public RelayCommand OpenContactListWindowCommand { get;  set; }
        public RelayCommand<object> ShowHideContactlistCommand { get; set; }
        public RelayCommand<ViewModelTab> CloseTabCommand { get; set; }
        public RelayCommand<TabReorder> TabsReorderedCommand { get; set; }
        public RelayCommand OpenNotificationsWindowCommand { get; set; }
        public RelayCommand CloseNotificationsBarCommand { get; set; }
        public RelayCommand<ViewModelTab> CloseAllTabsCommand { get; set; }
        public RelayCommand<ViewModelTab> PinTabCommand { get; set; }
        public RelayCommand StartUpdateCheckCommand { get; set; }
        public RelayCommand ShowAboutWindowCommand { get; set; }
        public RelayCommand OpenWelcomeTabCommand { get; set; }

        private ObservableCollection<ViewModelTab> _chatViewModels;
        public ObservableCollection<ViewModelTab> ChatViewModels
        {
            get
            {
                if (_chatViewModels == null)
                {
                    var locator = (ViewModelLocator)Application.Current.Resources["Locator"];
                    SortedObservableCollection<ViewModelTab> items = new SortedObservableCollection<ViewModelTab>();
                    items.Add(new ViewModelPrivateMessage(locator.CurrentClient, locator.ViewModelContactList.Contacts[0],VmHelper.Locator.ViewModelContactList.CurrentUser,false,false));
                    foreach (ChatGroup grp in locator.CurrentClient.CurrentUserInfo.ChatGroups.Take(2))
                    {
                        JiveChatGroupModel m = new JiveChatGroupModel(grp.ID, grp.Name,grp.GroupMembers);
                        ViewModelGroupChat vmg = new ViewModelGroupChat(locator.CurrentClient, m,VmHelper.Locator.ViewModelContactList.CurrentUser,false,false);
                        Random rng = new Random();
                        vmg.IsPinned = rng.Next(1, 100) > 50 ? true : false;
                        //vmg.DisplayMessage(locator.ViewModelContactList.CurrentUser, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus feugiat non enim eget dapibus. Sed viverra risus vitae tristique pulvinar. ", DisplayMessageOptions.ChatMessageOption, DateTime.Now);
                        items.Add(vmg);
                    }
                    _chatViewModels = items;
                }
                return _chatViewModels;
            }
            set
            {
                _chatViewModels = value;
            }
        }

        public ViewModelTab CurrentActiveViewModel
        {
            get
            {
                return ChatViewModels[0];
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public bool IsChatControlVisible
        {
            get
            {
                return true;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool IsLoginControlVisible
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }



        public void RunOnNetworkConnect()
        {

        }

        public void RunOnNetworkDisconnect()
        {

        }

        public bool IsMainMenuVisible
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string WindowTitle
        {
            get
            {
                return "Window title here";
            }
            set
            {
                throw new NotImplementedException();
            }
        }



        public bool IsAnimatingContactList
        {
            get
            {
                return false;
            }
            set
            {
                throw new NotImplementedException();
            }
        }


        public void RestoreTabs()
        {
            throw new NotImplementedException();
        }
    }
}
